package com.kzj.laimeimei.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.kzj.laimeimei.R;
import com.kzj.laimeimei.activity.GBaseActivity;
import com.kzj.laimeimei.recyclerCard.basic.CardItemView;
import com.kzj.laimeimei.recyclerCard.card.other.CityCard;

import de.greenrobot.event.EventBus;

/**
 * Created by xyg on 2015/10/26.
 */
public class CityCardView extends CardItemView<CityCard> {

    private Context context;
    private TextView textView_city;

    public CityCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CityCardView(Context context) {
        super(context);
        this.context = context;
    }

    public CityCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final CityCard card) {
        super.build(card);
        textView_city = (TextView) findViewById(R.id.textView_city);
        textView_city.setText(card.getCityBean().getCity_name());
        textView_city.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(card.getCityBean());
                ((GBaseActivity)context).finish();
            }
        });
    }
}
